﻿<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
  
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Class RNN
   </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Class RNN
   ">
    <meta name="generator" content="docfx 2.42.4.0">
    
    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../styles/docfx.css">
    <link rel="stylesheet" href="../styles/main.css">
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> 
    <meta property="docfx:navrel" content="../toc.html">
    <meta property="docfx:tocrel" content="toc.html">
    
    
    
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
  <script defer="" src="https://code.getmdl.io/1.3.0/material.min.js"></script>
  </head>  <body data-spy="scroll" data-target="#affix" data-offset="120">
    <div id="wrapper">
      <header>
        
        <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              
              <a class="navbar-brand" href="../index.html">
                <img id="logo" class="svg" src="../logo.svg" alt="">
              </a>
            </div>
            <div class="collapse navbar-collapse" id="navbar">
              <form class="navbar-form navbar-right" role="search" id="search">
                <div class="form-group">
                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
                </div>
              </form>
            </div>
          </div>
        </nav>
        
        <div class="subnav navbar navbar-default">
          <div class="container hide-when-search" id="breadcrumb">
            <ul class="breadcrumb">
              <li></li>
            </ul>
          </div>
        </div>
      </header>
      <div role="main" class="container body-content hide-when-search">
        
        <div class="sidenav hide-when-search">
          <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
          <div class="sidetoggle collapse" id="sidetoggle">
            <div id="sidetoc"></div>
          </div>
        </div>
        <div class="article row grid-right">
          <div class="col-md-10">
            <article class="content wrap" id="_content" data-uid="Keras.Layers.RNN">
  
  
  <h1 id="Keras_Layers_RNN" data-uid="Keras.Layers.RNN" class="text-break">Class RNN
  </h1>
  <div class="markdown level0 summary"><p>Base class for recurrent layers.
This layer supports masking for input data with a variable number of timesteps. To introduce masks to your data, use an Embedding layer with the mask_zero parameter set to True.</p>
<p>
You can set RNN layers to be &apos;stateful&apos;, which means that the states computed for the samples in one batch will be reused as initial states for the samples in the next batch. This assumes a one-to-one mapping between samples in different successive batches.
To enable statefulness: - specify stateful = True in the layer constructor. - specify a fixed batch size for your model, by passing if sequential model: batch_input_shape = (...) to the first layer in your model. else for functional model with 1 or more Input layers: batch_shape = (...) to all the first layers in your model.This is the expected shape of your inputs including the batch size.It should be a tuple of integers, e.g. (32, 10, 100). - specify shuffle = False when calling fit().
To reset the states of your model, call.reset_states() on either a specific layer, or on your entire model.
</p>
<p>
You can specify the initial state of RNN layers symbolically by calling them with the keyword argument initial_state. 
The value of initial_state should be a tensor or list of tensors representing the initial state of the RNN layer.
You can specify the initial state of RNN layers numerically by calling reset_states with the keyword argument states.The value of states should be a numpy array or list of numpy arrays representing the initial state of the RNN layer.
</p>
<p>
You can pass &quot;external&quot; constants to the cell using the constants keyword argument of RNN.__call__ (as well as RNN.call) method. This requires that the cell. 
Call method accepts the same keyword argument constants. Such constants can be used to condition the cell transformation on additional static inputs (not changing over time), a.k.a. an attention mechanism.
</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><span class="xref">System.Object</span></div>
    <div class="level1"><a class="xref" href="Keras.Keras.html">Keras</a></div>
    <div class="level2"><a class="xref" href="Keras.Base.html">Base</a></div>
    <div class="level3"><a class="xref" href="Keras.Layers.BaseLayer.html">BaseLayer</a></div>
    <div class="level4"><span class="xref">RNN</span></div>
      <div class="level5"><a class="xref" href="Keras.Layers.ConvLSTM2D.html">ConvLSTM2D</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.ConvLSTM2DCell.html">ConvLSTM2DCell</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.CuDNNGRU.html">CuDNNGRU</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.CuDNNLSTM.html">CuDNNLSTM</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.GRU.html">GRU</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.GRUCell.html">GRUCell</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.LSTM.html">LSTM</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.LSTMCell.html">LSTMCell</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.SimpleRNN.html">SimpleRNN</a></div>
      <div class="level5"><a class="xref" href="Keras.Layers.SimpleRNNCell.html">SimpleRNNCell</a></div>
  </div>
  <div classs="implements">
    <h5>Implements</h5>
    <div><span class="xref">System.IDisposable</span></div>
  </div>
  <div class="inheritedMembers">
    <h5>Inherited Members</h5>
    <div>
      <a class="xref" href="Keras.Layers.BaseLayer.html#Keras_Layers_BaseLayer_Set_Keras_Layers_BaseLayer___">BaseLayer.Set(BaseLayer[])</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_Parameters">Base.Parameters</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_None">Base.None</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_Init">Base.Init()</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_ToPython">Base.ToPython()</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_InvokeStaticMethod_System_Object_System_String_System_Collections_Generic_Dictionary_System_String_System_Object__">Base.InvokeStaticMethod(Object, String, Dictionary&lt;String, Object&gt;)</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_InvokeMethod_System_String_System_Collections_Generic_Dictionary_System_String_System_Object__">Base.InvokeMethod(String, Dictionary&lt;String, Object&gt;)</a>
    </div>
    <div>
      <a class="xref" href="Keras.Base.html#Keras_Base_Item_System_String_">Base.Item[String]</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_Instance">Keras.Instance</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_keras">Keras.keras</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_keras2onnx">Keras.keras2onnx</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_tfjs">Keras.tfjs</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_Dispose">Keras.Dispose()</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_ToTuple_System_Array_">Keras.ToTuple(Array)</a>
    </div>
    <div>
      <a class="xref" href="Keras.Keras.html#Keras_Keras_ToList_System_Array_">Keras.ToList(Array)</a>
    </div>
    <div>
      <span class="xref">System.Object.Equals(System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.Equals(System.Object, System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.GetHashCode()</span>
    </div>
    <div>
      <span class="xref">System.Object.GetType()</span>
    </div>
    <div>
      <span class="xref">System.Object.MemberwiseClone()</span>
    </div>
    <div>
      <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.ToString()</span>
    </div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="Keras.Layers.html">Keras.Layers</a></h6>
  <h6><strong>Assembly</strong>: Keras.dll</h6>
  <h5 id="Keras_Layers_RNN_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class RNN : BaseLayer, IDisposable</code></pre>
  </div>
  <h3 id="constructors">Constructors
  </h3>
  <span class="small pull-right mobile-hide">
    <span class="divider">|</span>
    <a href="https://github.com/SciSharp/Keras.NET/new/master/apiSpec/new?filename=Keras_Layers_RNN__ctor.md&amp;value=---%0Auid%3A%20Keras.Layers.RNN.%23ctor%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  </span>
  <span class="small pull-right mobile-hide">
    <a href="https://github.com/SciSharp/Keras.NET/blob/master/Keras/Layers/Recurrent.cs/#L31">View Source</a>
  </span>
  <a id="Keras_Layers_RNN__ctor_" data-uid="Keras.Layers.RNN.#ctor*"></a>
  <h4 id="Keras_Layers_RNN__ctor" data-uid="Keras.Layers.RNN.#ctor">RNN()</h4>
  <div class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="Keras.Layers.RNN.html">RNN</a> class.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public RNN()</code></pre>
  </div>
  <span class="small pull-right mobile-hide">
    <span class="divider">|</span>
    <a href="https://github.com/SciSharp/Keras.NET/new/master/apiSpec/new?filename=Keras_Layers_RNN__ctor_Keras_Layers_RNN_System_Boolean_System_Boolean_System_Boolean_System_Boolean_System_Boolean_System_Nullable_System_Int32__System_Nullable_System_Int32__Keras_Shape_.md&amp;value=---%0Auid%3A%20Keras.Layers.RNN.%23ctor(Keras.Layers.RNN%2CSystem.Boolean%2CSystem.Boolean%2CSystem.Boolean%2CSystem.Boolean%2CSystem.Boolean%2CSystem.Nullable%7BSystem.Int32%7D%2CSystem.Nullable%7BSystem.Int32%7D%2CKeras.Shape)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
  </span>
  <span class="small pull-right mobile-hide">
    <a href="https://github.com/SciSharp/Keras.NET/blob/master/Keras/Layers/Recurrent.cs/#L48">View Source</a>
  </span>
  <a id="Keras_Layers_RNN__ctor_" data-uid="Keras.Layers.RNN.#ctor*"></a>
  <h4 id="Keras_Layers_RNN__ctor_Keras_Layers_RNN_System_Boolean_System_Boolean_System_Boolean_System_Boolean_System_Boolean_System_Nullable_System_Int32__System_Nullable_System_Int32__Keras_Shape_" data-uid="Keras.Layers.RNN.#ctor(Keras.Layers.RNN,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Nullable{System.Int32},System.Nullable{System.Int32},Keras.Shape)">RNN(RNN, Boolean, Boolean, Boolean, Boolean, Boolean, Nullable&lt;Int32&gt;, Nullable&lt;Int32&gt;, Shape)</h4>
  <div class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="Keras.Layers.RNN.html">RNN</a> class.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public RNN(RNN cell, bool return_sequences = false, bool return_state = false, bool go_backwards = false, bool stateful = false, bool unroll = false, int? input_dim = default(int? ), int? input_length = default(int? ), Shape input_shape = null)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="Keras.Layers.RNN.html">RNN</a></td>
        <td><span class="parametername">cell</span></td>
        <td><p>A RNN cell instance.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">return_sequences</span></td>
        <td><p>Boolean. Whether to return the last output in the output sequence, or the full sequence.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">return_state</span></td>
        <td><p>Boolean. Whether to return the last state in addition to the output.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">go_backwards</span></td>
        <td><p>Boolean (default False). If True, process the input sequence backwards and return the reversed sequence.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">stateful</span></td>
        <td><p>Boolean (default False). If True, the last state for each sample at index i in a batch will be used as initial state for the sample of index i in the following batch.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">unroll</span></td>
        <td><p>Boolean (default False). If True, the network will be unrolled, else a symbolic loop will be used. Unrolling can speed-up a RNN, although it tends to be more memory-intensive. Unrolling is only suitable for short sequences.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Nullable</span>&lt;<span class="xref">System.Int32</span>&gt;</td>
        <td><span class="parametername">input_dim</span></td>
        <td><p>dimensionality of the input (integer). This argument (or alternatively, the keyword argument input_shape) is required when using this layer as the first layer in a model..</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Nullable</span>&lt;<span class="xref">System.Int32</span>&gt;</td>
        <td><span class="parametername">input_length</span></td>
        <td><p>Length of input sequences, to be specified when it is constant. This argument is required if you are going to connect  Flatten then Dense layers upstream (without it, the shape of the dense outputs cannot be computed). Note that if the recurrent layer is not the first layer in your model, you would need to specify the input length at the level of the first layer (e.g. via the input_shape argument)</p>
</td>
      </tr>
      <tr>
        <td><a class="xref" href="Keras.Shape.html">Shape</a></td>
        <td><span class="parametername">input_shape</span></td>
        <td><p>3D tensor with shape (batch_size, timesteps, input_dim).</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="implements">Implements</h3>
  <div>
      <span class="xref">System.IDisposable</span>
  </div>
</article>
          </div>
          
          <div class="hidden-sm col-md-2" role="complementary">
            <div class="sideaffix">
              <div class="contribution">
                <ul class="nav">
                  <li>
                    <a href="https://github.com/SciSharp/Keras.NET/new/master/apiSpec/new?filename=Keras_Layers_RNN.md&amp;value=---%0Auid%3A%20Keras.Layers.RNN%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
                  </li>
                  <li>
                    <a href="https://github.com/SciSharp/Keras.NET/blob/master/Keras/Layers/Recurrent.cs/#L26" class="contribution-link">View Source</a>
                  </li>
                </ul>
              </div>
              <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
              <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
              </nav>
            </div>
          </div>
        </div>
      </div>
      
      <footer>
        <div class="grad-bottom"></div>
        <div class="footer">
          <div class="container">
            <span class="pull-right">
              <a href="#top">Back to top</a>
            </span>
            
            <span>Generated by <strong>DocFX</strong></span>
          </div>
        </div>
      </footer>
    </div>
    
    <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
    <script type="text/javascript" src="../styles/docfx.js"></script>
    <script type="text/javascript" src="../styles/main.js"></script>
  </body>
</html>
